package resolver

// This file will be automatically regenerated based on the schema, any resolver implementations
// will be copied through when generating and any unknown code will be moved to the end.

import (
	"context"
	"fmt"
	"gqlt2/graph/model"
	"io/ioutil"

	"github.com/99designs/gqlgen/graphql"
)

func (r *mutationResolver) FileUpload(ctx context.Context, file graphql.Upload, fileType int) (*model.FileUploaderResult, error) {
	fmt.Println(file.Size)
	fmt.Println(file.ContentType)
	fmt.Println(file.Filename)
	fmt.Println(fileType)
	bytes, err := ioutil.ReadAll(file.File)
	if err != nil {
		return nil, err
	}
	err = ioutil.WriteFile("D:\\t.txt", bytes, 0666)
	if err != nil {
		return nil, err
	}
	return &model.FileUploaderResult{URL: "http://www.baidu.com"}, nil
}
